﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

namespace DataLayer
{
    public class dlInsertMember
    {
        public void Insertmember(string loginnaam, string paswoord, string naam, string voornaam, int roleid)
        {
            string mijnconnectiestring;

            mijnconnectiestring = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;

            SqlConnection conn = new SqlConnection(mijnconnectiestring);

            // might have to  before insert

            conn.Open();

            string insertString = "insert into Users (Login, Passwoord, Name, FirstName, RoleId) values (@loginnaam, @paswoord, @naam, @voornaam, @roleid)";

            SqlCommand Query = new SqlCommand(insertString, conn);

            Query.Parameters.AddWithValue("@loginnaam", loginnaam);
            Query.Parameters.AddWithValue("@paswoord", paswoord);
            Query.Parameters.AddWithValue("@naam", naam);
            Query.Parameters.AddWithValue("@voornaam", voornaam);
            Query.Parameters.AddWithValue("@roleid", roleid);

            Query.ExecuteNonQuery();
            conn.Close();
        }
        public void InsertmemberToTeam(int userid, int teamid)
        {
            string mijnconnectiestring;

            mijnconnectiestring = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;

            SqlConnection conn = new SqlConnection(mijnconnectiestring);

            conn.Open();

            string insertString = "insert into TeamUser (TeamId, UserId) values (@teamid, @userid)";

            SqlCommand Query = new SqlCommand(insertString, conn);

            Query.Parameters.AddWithValue("@userid", userid);
            Query.Parameters.AddWithValue("@teamid", teamid);

            Query.ExecuteNonQuery();

            conn.Close();
        }
        public void Insertteam(string teamnaam)
        {

            string mijnconnectiestring;

            mijnconnectiestring = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;

            SqlConnection conn = new SqlConnection(mijnconnectiestring);

            conn.Open();

            string insertString = "insert into Teams (Name) values (@teamnaam)";

            SqlCommand Query = new SqlCommand(insertString, conn);

            Query.Parameters.AddWithValue("@teamnaam", teamnaam);

            Query.ExecuteNonQuery();

            conn.Close();

            


        }

    }
}
